'use client'

import { ConfigProvider } from 'antd'
import { usePathname } from 'next/navigation'
import zhCN from 'antd/locale/zh_CN'
import { antdTheme } from '../config/antd'

import Header from './Header'
import Footer from './Footer'

export default function Layout({ children }) {
    const pathname = usePathname()

    // 首页、登录、注册页不显示header和footer
    const isAuthPage = pathname === '/' || pathname === '/login' || pathname === '/register'

    return (
        <ConfigProvider
            locale={zhCN}
            theme={antdTheme}
            warning={{
                strict: false,
            }}
        >
            <div className={`min-h-screen ${isAuthPage ? '' : 'bg-gray-50'}`}>
                {!isAuthPage && <Header />}
                <main className="flex-1">
                    {children}
                </main>
                {!isAuthPage && <Footer />}
            </div>
        </ConfigProvider>
    )
}